
#ifndef SHM_COMMON_H
#define SHM_COMMON_H

// FOR INERNAL USE ONLY!!

#include "channel.h"
#include <pthread.h>


#define LINE_SIZE (16) // line size: 16 bytes to work with simd code

//#define LINE_SIZE (8) // line size: 8 bytes on ottavinareale



void mutex_init( pthread_mutex_t *mutex );
void cond_init( pthread_cond_t *cond );

void __LCwakeUpAlternative( key_t altKey );
inline void __LCsetAltKey( struct channel_t *ch, key_t altKey );

inline int __LClockChannel( struct channel_t *ch );
inline int __LCunlockChannel( struct channel_t *ch );
inline int __LCwaitOnChannel( struct channel_t *ch );
inline int __LCwakeUpChannel( struct channel_t *ch );

inline int __LClockAlt( struct alternative_t *alt );
inline int __LCunlockAlt( struct alternative_t *alt );
inline int __LCwaitOnAlt( struct alternative_t *alt );
inline int __LCwakeUpAlt( struct alternative_t *alt );

#endif
